// var crypto = require('crypto');
// const secret = 'abcdefg';
// const hash = crypto.createHmac('sha256', secret)
//     .update('I love cupcakes')//加盐
//     .digest('hex');
// console.log(hash);

var bcrypt = require('bcrypt');
async function getPass() {
    // 加盐
    const salt = await bcrypt.genSalt(10);
    // 加密
    const pass = await bcrypt.hash('luojianming', salt);
    console.log(pass);
    // 比较
    var res = await bcrypt.compare('luojianming', '$2b$10$je4Fyp6MpbwJ.qGsNhquG.mT9mLm7O5fk.UfFG5FfsYc0BaIFR0Oy');
    console.log(res);
}
getPass();